﻿function DelTask() {
    var cf = "";
    var tree = mini.get("treegrid");
    var rows = tree.getSelecteds();
    var jd = false;
    var task_ids = [];
    var parent_task_ids = [];
    for (var i = 0; i < rows.length; i++) {
        var row = rows[i];
        task_ids.push(row.task_id_);
        parent_task_ids.push(row.parent_task_id_);
        if (!tree.isLeafNode(row)) {
            jd = true;
        }
    }
    if (task_ids.length > 0) {
        if (jd) {
            cf = "要删除的任务中有分解子任务，确定删除所有任务？";
        }
        else {
            cf = "确定删除选中的任务吗？";
        }
        if (confirm(cf)) {
            $.ajax({
                url: "/AJAX/AjaxService.aspx?method=DelTask",
                type: "post",
                cache: false,
                async: true,
                data: { task_ids_: task_ids, parent_task_ids_: parent_task_ids },
                success: function (text) {

                    //var o = mini.decode(text);
                    //alert(o.res + o.error);
                },
                error: function (jqXHR, textStatus, errorThrown) {

                }
            });
            tree.reload();
        }
    }
    else {
        alert("没有选中任何行！");
    }
}
